package com.coreJava.bingfabao;

import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;

/**
 * 作者: LCG
 * 日期: 2020/2/10 23:20
 * 描述:
 */
public class TestCount2 implements Runnable {

    private CountDownLatch countDownLatch;

    public TestCount2(CountDownLatch countDownLatch) {
        this.countDownLatch = countDownLatch;
    }

    private CyclicBarrier cyclicBarrier;

    public TestCount2(CyclicBarrier cyclicBarrier) {
        this.cyclicBarrier = cyclicBarrier;
    }

    @Override
    public void run() {

        try {
            Thread.sleep(5000L);
            System.out.println("========等待集合====比如赛跑==远动员="+Thread.currentThread().getName()+"就位");
            cyclicBarrier.await();
            System.out.println("=====起跑==========="+Thread.currentThread().getName());
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (BrokenBarrierException e) {
            e.printStackTrace();
        }
    }
}
